<!--
 * @Description: 
 * @Date: 2023-03-29 15:37:32
 * @LastEditTime: 2023-04-11 22:58:09
 * @Author: Black
 * @FilePath: \store_admin\src\layouts\components\fragments_tablist.vue
-->
<template>
  <div class="fragments_tablist" :style="{ left: $store.state.asideWidth }">

    <el-tabs v-model="activeTab" @tab-change="changeTab" @tab-remove="removeTab" type="card" class="flex-1 mr-2"
      style="min-width: 100px;">
      <el-tab-pane :closable="item.path != '/'" v-for="item in tabList" @tab-remove="removeTab" :key="item.path"
        :label="item.title" :name="item.path">
      </el-tab-pane>
    </el-tabs>

    <span class="tab_btn">
      <el-dropdown @command="handleCloseTabs">
        <span class="el-dropdown-link">
          <el-icon>
            <arrow-down />
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item command="clearOther">关闭其他</el-dropdown-item>
            <el-dropdown-item command="clearAll">全部关闭</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </span>
    
  </div>
  <div class="h-[40px]"></div>
</template>

<script setup>
import { useTabList } from '~/composables/useTabList'

const {
  activeTab,
  tabList,
  changeTab,
  removeTab,
  handleCloseTabs
} = useTabList()

</script>

<style scoped>
.fragments_tablist {
  @apply fixed bg-gray-100 flex justify-center items-center px-2;
  top: 64px;
  right: 0;
  height: 56px;
  /* height: 44px; */
  z-index: 100;
}

.tab_btn {
  position: absolute;
  right: 20px;
  height: 32px;
  z-index: 200;
  @apply bg-white rounded ml-auto flex justify-center items-center px-2 border;
}

:deep(.el-tabs__header) {
  @apply mb-0;
  height: 0%;
  border-bottom: 0;
  left: 10px;
}

:deep(.el-tabs__nav) {
  border: 0 !important;
}

:deep(.el-tabs__item) {
  border: 0px !important;
  height: 32px;
  line-height: 32px;
  @apply bg-white mx-1 rounded;
}

:deep(.el-tabs__nav-next),
:deep(.el-tabs__nav-prev) {
  line-height: 32px;
  height: 32px;
}

:deep(.is-disabled) {
  cursor: not-allowed;
  @apply text-gray-300;
}
</style>